package com.yiwyn.unity.domain;

import com.yiwyn.demo.utils.modify.entity.ModifyEntity;
import com.yiwyn.demo.utils.modify.handle.event.base.BaseEvent;

import java.util.HashMap;
import java.util.Map;

public abstract class BaseModifyTemp<T> {

    private Map<String, BaseEvent> map = new HashMap<>();


    public BaseModifyTemp() {
        register();
    }

    public void register() {
        initEvent();
    }

    public void trigger(String eventId, ModifyEntity.ModifyItem modifyItem) {
        map.get(eventId).trigger(modifyItem);
    }

    private void initEvent() {
        map.put("yn", modifyItem -> {
            modifyItem.setNewValueDescription(modifyItem.getNewValue().equals("Y") ? "是" : "否");
            modifyItem.setOldValueDescription(modifyItem.getOldValue().equals("Y") ? "是" : "否");
        });

    }
}